package com.gscitysfy.cus.drain.modules.resource.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cus.drain.annotations.DictTranslation;
import com.gscitysfy.cus.drain.annotations.FieldParam;
import com.gscitysfy.cus.drain.constants.DicConstant;
import com.gscitysfy.cus.drain.modules.resource.dto.DrainBaseChGoodsRequest;
import com.gscitysfy.cus.drain.modules.resource.dto.DrainBaseChGoodsResponse;
import com.gscitysfy.cus.drain.modules.resource.dto.DrainBaseChGoodsStatistics;
import com.gscitysfy.cus.drain.modules.resource.service.IDrainBaseChGoodsService;
import com.gscitysfy.cus.drain.modules.resource.service.IDrainBaseMnWarehouseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 仓库物资子表 前端控制器
 * </p>
 *
 * @author user
 * @since 2022-10-24 16:58:09
 */
@Tag(name = "资源管理 -> 仓库物资子表")
@AllArgsConstructor
@RestController
@RequestMapping("/resource/drain-base-ch-goods")
public class DrainBaseChGoodsController {
    @Resource
    private IDrainBaseChGoodsService drainBaseChGoodsService;

    @Operation(summary = "仓库物资")
    @PutMapping(value = "/delete/{id}")
    public Result<Boolean> delete(@PathVariable Long id) {
        return Result.content(drainBaseChGoodsService.delete(id));
    }

    @Resource
    private IDrainBaseMnWarehouseService drainBaseMnWarehouseService;

    @Operation(summary = "仓库物资子表列表")
    @GetMapping("/page")
    @DictTranslation({
            @FieldParam(dictType = DicConstant.YAYJWZLX_TYPE, targetField = "goodsType"),
    })
    public Result<IPage<DrainBaseChGoodsResponse>> page(@Parameter(hidden = true) Page<DrainBaseChGoodsRequest> page, @Parameter(hidden = true) DrainBaseChGoodsRequest request) {
        return Result.content(drainBaseChGoodsService.getByPage(page, request));
    }

    @Operation(summary = "仓库物资子表列表")
    @GetMapping("/iconStatistics")
    public Result<List<DrainBaseChGoodsStatistics>> iconStatistics(@Parameter(hidden = true) DrainBaseChGoodsRequest request) {
        return Result.content(drainBaseChGoodsService.iconStatistics(request));
    }

    @Operation(summary = "导出")
    @GetMapping("/export")
    public void export(HttpServletResponse response,@RequestParam("ids") List<String> ids) {
        drainBaseChGoodsService.export(response,ids);
    }

}
